<?php
include_once 'conn.php';
$sql = "select carName,carNum from carinfo order by carNum desc";
$result = mysqli_query($conn, $sql);
$type = $_GET['type'] ?? '0';
if($type == 3){
    $a = array();
    while ($info = mysqli_fetch_array($result)) {
        $b = array('name'=>$info['carName'],'value'=>$info['carNum']);
        array_push($a, $b);
    }
}
else{
    $a['categories'] = array();
    $a['data'] = array();
    while ($info = mysqli_fetch_array($result)) {
        array_push($a['categories'], $info['carName']);
        array_push($a['data'], $info['carNum']);
    }
}
echo json_encode($a);
?>

